const obj = {
  name: "yz",
  age: 18
}

const objProxy = new Proxy(obj, {
  // 获取值时的捕获器
  get: function(target, key, receiver) {
    console.log("get访问")
    return Reflect.get(target, key)
  },
  // 设置值时的捕获器
  set: function(target, key, newValue, receiver) {
    console.log("set设置");
    const result = Reflect.set(target, key, newValue)
    if(result) {
      console.log("设置成功");
    } else {
      console.log("设置失败");
    }
  },
})

objProxy.name = "jay"
console.log(objProxy.name);
